#include"UdpServer.hpp"
#include<memory>
#include"Dict.hpp"
using namespace std;

// ./udp_server local-port
// ./udp_server 8888
//        0       1
int main(int argc, char *argv[])
{
    if(argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " local-port" << std::endl;
        exit(0);
    }
    uint16_t port = stoi(argv[1]);
    EnableScreen();

    Dict dict("./dict.txt");
    func_t translate = std::bind(&Dict::Translate, &dict, std::placeholders::_1);//将dict的类和服务器的类进行绑定

    unique_ptr<UdpServer> usvr = make_unique<UdpServer>(translate,port);
    usvr->InitServer();
    usvr->Start();

    return 0;
}